#!/bin/bash

# 查找指定名称的 Java 进程的 PID
pids=$(ps -ef | grep java | grep "homework-management-0.0.1-SNAPSHOT.jar" | grep -v grep | awk '{print $2}')

# 检查是否找到了进程
if [ -z "$pids" ]; then
    echo "未找到名为 $process_name 的 Java 进程。"
else
    # 终止进程
    for pid in $pids; do
        echo "正在终止进程 $pid..."
        kill -9 $pid
        if [ $? -eq 0 ]; then
            echo "进程 $pid 已成功终止。"
        else
            echo "终止进程 $pid 时出错。"
        fi
    done
fi


git pull
cd findFun-backend
mvn clean package
cd runtime
cp ../target/homework-management-0.0.1-SNAPSHOT.jar .
nohup java -Djava.net.preferIPv4Stack=true -jar homework-management-0.0.1-SNAPSHOT.jar &
